$(function(){
    $(".amend_btn").on("click",function(){
        var token=sessionStorage.getItem("token");
        var old_pay_pwd1=$("#old_pay_pwd").val();
        var pay_pwd2=$("#pay_pwd").val();
        var pay_pwd3=$("#pay_pwd1").val();
        if(old_pay_pwd1 == "" || old_pay_pwd1 == null){
            alert("请输入原支付密码");
            return false;
        }
        if(pay_pwd2 == "" || pay_pwd2 == null){
            alert("请输入新支付密码");
            return false;
        }
        if(pay_pwd2 != pay_pwd3){
            alert("两次输入的支付密码不一致");
            return false;
        }
        var url="http://www.rice.com/app/api/h5_access";
        var d={};
        d.method="User|set_pay_pwd";
        d.token=token;
        d.type=1;
        d.old_pay_pwd=old_pay_pwd1;
        d.pay_pwd=pay_pwd2;
        //支付
        $.ajax({
            type:"post",
            url:url,
            data:d,
            dataType:"json",
            success:function(result){
                if(result.status=="1"){
                    alert(result.message);
                    location.href="setting.html";
                }else if(result.status=="2"){
                    alert(result.message);
                    location.href="login.html";
                }else{
                    alert(result.message);
                }
            }
        })
    })
    //验证登陆状态
    var token=sessionStorage.getItem("token");
    var url="http://www.rice.com/app/api/h5_access";
    var d={};
   d.method="get_user_msg";
   d.token=token;
   //支付
   $.ajax({
       type:"post",
       url:url,
       data:d,
       dataType:"json",
       success:function(result){
           if(result.status=="1"){
               var data=result.data;
               var realname_confirm=data.realname_confirm;
               var merchant_confirm=data.merchant_confirm;
               var img_confirm=data.img_confirm;
               var has_activity=data.has_activity;
              sessionStorage.setItem("realname_confirm",realname_confirm);
              sessionStorage.setItem("merchant_confirm",merchant_confirm);
              sessionStorage.setItem("img_confirm",img_confirm);
              sessionStorage.setItem("has_activity",has_activity);
           }
          if(result.status=="2"){
              alert(result.message);
              location.href="login.html";
           }
       }
   })
})